import requests
import json

def JStoPy():
    url_JS = "https://www.runoob.com/api/compile.php"
    header={
        'Accept': '*/*',
        'Accept-Encoding': 'gzip, deflate, br',
        'Accept-Language': 'zh-CN,zh;q=0.9',
        'Connection': 'keep-alive',
        'Content-Length': '8803',
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
        'Host': 'www.runoob.com',
        'Origin': 'https://www.runoob.com',
        'Referer': 'https://www.runoob.com/try/runcode.php?filename=helloworld&type=nodejs',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3676.400 QQBrowser/10.4.3505.400',
        'X-Requested-With': 'XMLHttpRequest'
    }
    js_code = open('asANDcp.js','r').read()
    data = {
    'code': '{}'.format(js_code).encode(),
    'language': '4',
    'fileext': 'node.js'
    }
    req = requests.post(url=url_JS,data=data,headers=header).text
    return json.loads(req)["output"]

if __name__ == "__main__":
    print(JStoPy())